package flca.osm.perst.model;

import java.util.ArrayList;
import java.util.List;

import org.garret.perst.Persistent;

public class PWay extends Persistent
{
	private int id;
	private List<Integer> wayNodes = new ArrayList<Integer>();
//	private Map<String, String> tags = new HashMap<String, String>();
	
	
	public PWay(int id) {
		super();
		this.id = id;
	}

	public PWay(int id, List<Integer> wayNodes) {
		super();
		this.id = id;
		this.wayNodes = wayNodes;
//		this.tags = tags;
	}

	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public List<Integer> getWayNodes() {
		return wayNodes;
	}


	public void setWayNodes(List<Integer> wayNodes) {
		this.wayNodes = wayNodes;
	}


	public void addWayNode(Integer aRef) {
		wayNodes.add(aRef);
	}

	public void addWayNode(int aRef) {
		wayNodes.add(new Integer(aRef));
	}

//	public void addWayTag(String aKey, String aValue) {
//		tags.put(aKey,  aValue);
//	}

	public boolean isClosed() {
		return (wayNodes.get(0) != null && wayNodes.get(0).equals(wayNodes.get(wayNodes.size()-1)));
	}
	
	@Override
	public String toString() {
		String s = "MyWay [id=" + id + " nodes=";
		for (int nodeid : wayNodes) {
			s += nodeid + ",";
		}
		return s + "]";
	}
	
	
}
